﻿using Ivony.Html.Parser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ivony.Html;

namespace TaoPortal.HtmlCrawls
{
    public class Class1
    {
        public static void GetHtmlDocument()
        {
            JumonyParser a = new JumonyParser();
            var doc = a.LoadDocument("http://www.sina.com.cn/");
            //var elements = document.Find("#post_list > .post_item:nth-child(2)");

            var parser = new JumonyParser();

            var document = parser.LoadDocument("http://www.cnblogs.com/");

            var elements = document.Find("#post_list > .post_item");
            foreach (var e in elements)
            {
                Console.WriteLine("title: {0}", e.FindFirst("h3 > a").InnerText());
                Console.WriteLine("link: {0}", e.FindFirst("h3 > a").Attribute("href").Value());
                Console.WriteLine("votes: {0}", e.FindFirst(".diggnum").InnerText());
                Console.WriteLine("author: {0}", e.FindFirst(".post_item_foot a.lightblue").InnerText());
                Console.WriteLine(new string('-', 30));
            }

        }
    }
}
